import App from './App'

export function frame(url, frame=7000, {type='jpg', width=0, height=0}={}){
	const url2 = `${url}?x-oss-process=video/snapshot,t_${frame},f_${type},m_fast,w_${width},h_${height}`
	return url2
}
Vue.filter('frame', frame)

export function poster(url, poster="", duration=""){
	if(!poster){
		return frame(url, 7000, {width:375})
	}
	switch(typeof(poster)){
		// 自定义封面图
		case "string":
			return poster
		case "number":
			// 指定第几秒钟
			if(poster >= 0){
				return frame(url, parseInt(poster*1000), {width:375})
			}else if(poster == -1){		// 表示随机一帧
				const sec = parseInt(duration*Math.random())
				return frame(url, Math.round(sec*1000), {width:375})
			}
		break
		// 第一帧
		default:
			return frame(url, 7000, {width:375})
		break
	}
}
Vue.filter('poster', poster)

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
    ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'

export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif